public class Test {
    public static class TreeNode{
        public int val;
        public TreeNode left;
        public TreeNode right;
        TreeNode(int val){
            this.val = val;
        }
    }
        class Solution {
        public boolean isSymmetric(TreeNode root) {
            if(root==null){
                return true;
            }
            return isSymmetriChild(root.left,root.right);
        }

        public boolean isSymmetriChild(TreeNode leftChild,TreeNode rightChild){
            if(leftChild==null&&rightChild!=null || leftChild!=null&& rightChild==null){
                return false;
            }
            if(leftChild==null&& rightChild==null){
                return true;
            }
            if(leftChild.val!=rightChild.val){
                return false;
            }
            return isSymmetriChild(leftChild.left,rightChild.right)&&isSymmetriChild(rightChild.left,leftChild.right);
        }
    }
}
